package drive.Service.ServiceFormat;

import com.google.gson.Gson;
import drive.Mapper.ReportRecordMapper;
import drive.Model.ReportRecord;
import drive.Service.ServiceInterface.ReportRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
//已完成初步测试，2025.3.17
@Service
public class ReportRecordServiceA implements ReportRecordService {
    @Autowired
    private ReportRecordMapper reportRecordMapper;

    private Gson gson = new Gson();

    @Override
    public String findAll() {
        List<ReportRecord> list = reportRecordMapper.findAll();
        return gson.toJson(list);
    }

    @Override
    public String findByReportID(int reportID) {
        ReportRecord reportRecord = reportRecordMapper.findByReportID(reportID);
        return gson.toJson(reportRecord);
    }

    @Override
    public String findByReporterAndReportee(int reporterID, int reporteeID) {
        ReportRecord reportRecord = reportRecordMapper.findByReporterAndReportee(reporterID, reporteeID);
        return gson.toJson(reportRecord);
    }
    @Override
    public String add(ReportRecord reportRecord) {
        int result = reportRecordMapper.add(reportRecord);
        return "举报成功";
    }

    @Override
    public String update(ReportRecord reportRecord) {
        int result = reportRecordMapper.update(reportRecord);
        return "处理举报信息成功";
    }

    @Override
    public String delete(int reportID) {
        int result = reportRecordMapper.delete(reportID);
        return "已删除举报";
    }
}
